<template>
  <div class="components-warp">
    <Col span="8" style="color: #949495;text-align: right;">
        <span class="components-warp-span" style=" display: inline;"></span>
         <!--<Input v-model="formValidate.ladder" type="text" placeholder=""></Input> 户-->
         <Input style="width: 80px"  v-model="dataItem.unit" type="text" number placeholder=""></Input> 号
    </Col>
    <Col span="16">
      <FormItem label="关联户型：" prop="unit">
        <Select v-if="houseTypeList.length > 0"  v-model="dataItem.houseId"  multiple>
          <Option v-for="item in houseTypeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
        </Select>
        <p v-else>
          该楼盘尚未创建户型
        </p>
      </FormItem>
    </Col>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        buildingUnitHouses: {
          unit: '',
          houseId: ''
        }
      };
    },
    props: {
      index: {
        type: Number,
        required: true
      },
      dataItem: {
        type: Object,
        default: function() {
          return {
            unit: '',
            houseId: ''
          };
        }
      },
      houseTypeList: {
        type: Array,
        default: []
      }
    },
    watch: {
      buildingUnitHouses: {
        handler (newV, oldV) {
          // console.log(oldV)
          if (newV.unit.length === 0) {
            // console.log(11111)
            return false;
          }
          if (newV.houseId.length === 0) {
            // console.log(222)
            return false;
          }
          this.$emit('uploadData', {index: this.index, data: newV});
        },
        deep: true
      },
      dataItem: {
        handler (newV, oldV) {
          this.buildingUnitHouses = newV;
          // console.log(this.buildingUnitHouses);
        },
        deep: true
      }
    },
    methods: {
    }
  };
</script>

<style lang="scss" scoped>
  @import "../assets/sass/install";
  .components-warp-span:before{
    content: '*';
    display: inline-block;
    vertical-align: top;
    margin-right: 5px;
    height: 15px;
    line-height: 19px;
    font-family: "Microsoft YaHei";
    font-size: 16px;
    color: #ff3300;
  }
</style>
